

package cn.shengchao.examstar.distribute.model;

import cn.hutool.core.bean.BeanUtil;
import cn.shengchao.examstar.distribute.infrastrure.po.*;
import lombok.Data;

/**
 * @program: examstarapi
 * @description: 分销用户现有体系模板
 * @author: Xiong weiqiang
 * @create: 2025-03-26 13:50
 */
@Data
public class DistributeNodeRoleChainExistModel {
    private DistributeNodeInfo distributeNodeInfo;
    private DistributeNodeRole distributeNodeRole;
    private DistributeDeptInfo distributeDeptInfo;
    private DistributeDeptUserRoleBind distributeDeptUserRoleBind;
    private DistributeNodeRoleChain distributeNodeRoleChain;
    private DistributeNodeInfo upLevelNodeInfo;

    public boolean isExist() {
        return getDistributeNodeInfo() != null && getDistributeNodeRole() != null && getDistributeNodeRoleChain() != null;
    }

    public DistributeNodeRoleChainCreator buildCreatorFromExistModel() {
        DistributeNodeRoleChainCreator distributeNodeRoleChainCreator = new DistributeNodeRoleChainCreator();
        BeanUtil.copyProperties(getDistributeNodeInfo(), distributeNodeRoleChainCreator);
        distributeNodeRoleChainCreator.setPercentStable(getDistributeNodeRole().getPercentStable());
        return distributeNodeRoleChainCreator;
    }
}